<?php
$v_current_style_name = "odd_row";
$v_next_style_name="";
if(isset($_REQUEST['cate_id'])){
	$v_cate_id = $_REQUEST['cate_id'];
}else{
	$v_cate_id = 0;
}
$v_url_send_question = "index.php?fuseaction=DISPLAY_SINGLE_QA_QUESTION_FOR_SENDING&agency_id=".$v_agency_id."&cate_id=".$v_cate_id;
$v_number_of_cate = sizeof($arr_all_cate);
$v_number_of_agency = sizeof($arr_all_agency);
if ($v_number_of_agency > 0){
	for($k=0;$k< $v_number_of_agency;$k++){
		if($v_agency_id==$arr_all_agency[$k]['0']){
			$v_agency_name= $arr_all_agency[$k]['2'];
			break;
		}
	}
}?>
<table width="100%" cellpadding="0" cellspacing="0">
	<form action="index.php" method="post" name="frm_dsp_all_cate_by_agency">
	<input name="fuseaction" type="hidden" value="">
	<input type="hidden" name="agency_id" value="<?php echo $v_agency_id;?>">
	<tr><td height="5"></td></tr>
	<tr class="page_title">
		<td colspan="3"><?php echo CONST_QA_LIST_ALL_AGENCY_TITLE.">>".$v_agency_name;?></td>
	</tr>
	<tr><td height="20"></td></tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" >
	<tr> 
		<td class="send_qa_link" colspan="4">
			<a href="<?php echo $v_url_send_question;?>"><?php echo CONST_QA_QUESTION_FOR_ANSWER_TITLE;?></a>&nbsp;&nbsp;
			<img src="<?php echo $_ISA_IMAGE_URL_PATH?>send_qa.gif">
		</td>
	</tr>
	<tr><td height="10"></td></tr>	
	<tr>
		<td class="normal_label" ><?php echo CONST_CHOISE_AGENCY_LABEL; ?></td>
		<td class="normal_label" colspan="3">
		  <select name="sel_agency" class="normal_selectbox" onChange="show_page_cate_by_agency();">                
			<?php echo _generate_select_option($arr_all_agency,'0','0','2', $v_agency_id);?>
		  </select></td>			
	</tr>
	<tr><td height="10"></td></tr>
</table><?php
if ($v_number_of_cate > 0){ ?>
	<table class="list_table" width="100%" cellpadding="0" cellspacing="0">
	<col width="50%"><col width="50%"><?php
		$current_pos=0; // vi tri hien thoi 
		//So vong lap de lay danh sach linh vuc con
		$total_loop= $v_number_of_cate;
		$haft_loop= round($total_loop/2); // mot nua vong lap
		for($i=0;$i< $haft_loop;$i++){//(****)
			$j= $current_pos + $i; // vi tri lay linh vuc
			// day linh vuc ben trai
			$v_left_cate_id = $arr_all_cate[$j]['1'];
			$v_left_cate_name= $arr_all_cate[$j]['2'];	
			$v_left_number_qa=$arr_all_cate[$j]['4'];		
						
			$v_left_cate_url = "index.php?fuseaction=DISPLAY_ALL_QA_BY_CATE&cate_id=" . $v_left_cate_id . "&agency_id=".$v_agency_id;
			// day linh vuc ben phai
			$right_index= $j+ $haft_loop;  // vi tri lay linh vuc o day ben phai
			if(($right_index- $current_pos) < $total_loop){
				$v_right_cate_id = $arr_all_cate[$right_index]['1'];
				$v_right_cate_name = $arr_all_cate[$right_index]['2'];
				$v_right_number_qa=$arr_all_cate[$right_index]['4'];					

				$v_right_cate_url = "index.php?fuseaction=DISPLAY_ALL_QA_BY_CATE&cate_id=" . $v_right_cate_id . "&agency_id=".$v_agency_id;
			}
			if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}?>
		
			<tr class="<?php echo $v_current_style_name ?>"> 
				<td>
					<img src="<?php echo $_ISA_IMAGE_URL_PATH?>open.gif" >
					<a  href="<?php echo $v_left_cate_url;?>"><?php echo $v_left_cate_name;?></a><small class="number_label"><? echo " (".$v_left_number_qa.")";?></small>
				</td><?php
				if(($right_index- $current_pos) < $total_loop){?>	
					<td>
						<img src="<?php echo $_ISA_IMAGE_URL_PATH?>open.gif">
						<a  href="<?php echo $v_right_cate_url;?>"><?php echo $v_right_cate_name;?></a><small class="number_label"><? echo " (".$v_right_number_qa.")";?></small>
					</td><?php
				}else{ ?>
					<td>&nbsp;</td><?php
				}?>	
			</tr><?php 
		}// end for
		if ($v_current_style_name == "odd_row"){
			$v_next_style_name = "round_row";
		}else{
			$v_next_style_name = "odd_row";
		}
		echo _add_empty_row($haft_loop,CONST_LIMIT_QA_PER_PAGE,$v_current_style_name,$v_next_style_name,2);							
		$current_pos= $current_pos + $total_loop; ?>
	</table><?php
}else{ ?>
		<small class="normal_label"><?php echo CONST_NO_QA_MESSAGE; ?></small><?php
}?>
<table width="100%" cellpadding="0" cellspacing="0">
	<tr><td height="10pt"></td></tr>
	<tr align="center">
		<td><input Type="button" Name="btn_back" class="normal_button" value="<?php echo _CONST_BACK_BUTTON;?>" onClick="goback();"></td>
	</tr>
</form>		
</table>